#ifndef CCOINMECHIMPL_H_
#define CCOINMECHIMPL_H_


#include <iostream>
#include <mutex>
#include <QObject>
#include "IValidatorInterface.h"

// 投币器接口
class CCoinMechImpl : public QObject, public zl::IValidatorInterface
{
    Q_OBJECT
public:
    CCoinMechImpl();
    ~CCoinMechImpl();

    int32_t Initialize(const std::string &com, int32_t baud, zl::IValidatorObserver *obs) override;
    int32_t Uninitialize() override;
    int32_t Status() override;
    int32_t Reset() override;
    int32_t Setup() override;
    int32_t Enable() override;
    int32_t Disable() override;

protected:
    int32_t cmd_enable();
    int32_t cmd_disable();
    int32_t cmd_status();

    int32_t process_received_package(const QByteArray& pkg);

protected slots:
    void event_device_responsed();

private:
    struct DatalinkImpl;
    DatalinkImpl* impl_;
    std::mutex mutex_;
    bool init_flag_;
    bool enable_flag_;
    int32_t status_;

    zl::IValidatorObserver* obs_;
};

#endif // CCOINMECHIMPL_H_
